package com.jambo.yudada.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
@Data
@ConfigurationProperties(prefix = "oss.client")
public class OSSConfig {
   public String getEndpoint() {
      return endpoint;
   }

   public void setEndpoint(String endpoint) {
      this.endpoint = endpoint;
   }

   public String getAccessKeyId() {
      return accessKeyId;
   }

   public void setAccessKeyId(String accessKeyId) {
      this.accessKeyId = accessKeyId;
   }

   public String getAccessKeySecret() {
      return accessKeySecret;
   }

   public void setAccessKeySecret(String accessKeySecret) {
      this.accessKeySecret = accessKeySecret;
   }

   public String getBucket() {
      return bucketName;
   }

   public void setBucket(String bucket) {
      this.bucketName = bucket;
   }

   private String endpoint;
   private String accessKeyId;
   private String accessKeySecret;
   private String bucketName;
   @Bean
   public OSS getOssClient(){
      return new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
   }
}
